home *** CD-ROM | disk | FTP | other *** search
/ Teach Yourself VRML 2 in 21 Days / Teach Yourself VRML 2 in 21 Days.iso / mac / ISO9660 / SOURCE / Answers / teleport.wrl < prev    next >
Encoding:
Text File  |  1996-12-24  |  3.4 KB  |  117 lines  |  [TEXT/mdos]

  1. #VRML V2.0 utf8
  2.  
  3. PROTO Teleporter [
  4.     field    MFString url [ ]
  5.     field    SFColor  diffuseColor 0.6 0.6 0 ]
  6. {
  7.  
  8. Transform {
  9.     children [
  10.         DEF PS ProximitySensor {
  11.             size 1.2 1.75 1.2
  12.         }
  13.         DEF Transporter Transform {
  14.             scale 0.3 0.3 0.3
  15.             children [
  16.                 Transform {
  17.                     translation 0 -3 0
  18.                     children DEF FromPad Shape {
  19.                         geometry Cylinder{ 
  20.                             radius 2
  21.                             height 0.2
  22.                         }
  23.                         appearance Appearance {
  24.                             material Material {
  25.                                 diffuseColor IS diffuseColor
  26.                             }
  27.                         }
  28.                     }
  29.                 }
  30.                 Transform {
  31.                     translation 0 4 0
  32.                     children USE FromPad
  33.                 } 
  34.                 Collision {
  35.                     collide FALSE
  36.                     children Shape {
  37.                         geometry IndexedFaceSet {
  38.                             coord Coordinate {
  39.                                 point [ -1.4 -3 1.4, 1.4 -3 1.4, 
  40.                                         1.4 -3 -1.4, -1.4 -3 -1.4,
  41.                                         -1.4 4 1.4, 1.4 4 1.4, 
  42.                                          1.4 4 -1.4, -1.4 4 -1.4 ]
  43.                             }
  44.                             coordIndex [ 0 4 5 1 -1, 1 5 6 2 -1,
  45.                                  2 6 7 3 -1, 3 7 4 0 -1 ]
  46.                         }
  47.                         appearance Appearance {
  48.                             material DEF TP_MAT Material {
  49.                                 diffuseColor 0 0 0
  50.                                 specularColor 0 0 0
  51.                                 ambientIntensity 0
  52.                                 emissiveColor 0.6 0.6 0.6
  53.                                 transparency 1
  54.                             }
  55.                         }
  56.                     }
  57.                 } 
  58.             ]
  59.         }
  60.     ]
  61. }
  62.  
  63. DEF TP_TRANSP ScalarInterpolator {
  64.     key [ 0 0.4 0.6 1 ]
  65.     keyValue [ 1 0 0 1 ]
  66. }
  67.  
  68. DEF TP_COLOR ColorInterpolator {
  69.     key [0, .05, .125, .2, .27,
  70.          .35, .43, .4999, .5, .55,
  71.          .625, .7, .77, .85, .93, 1]
  72.     keyValue [.6 .6 .6,
  73.               1 1 1,
  74.               .2 .8 .2,
  75.               0 1 0,
  76.               0 0 0,
  77.               .2 .2 .7,
  78.               0 0 .2,
  79.               .2 .2 .2, 
  80.               .2 .2 .2, 
  81.               0 0 .2,
  82.               .2 .8 .2,
  83.               0 1 0,
  84.               0 0 0,
  85.               .2 .2 .7,
  86.               0 .2 0,
  87.               .6 .6 .6]
  88. },
  89.  
  90. DEF Time TimeSensor {
  91.     cycleInterval 10
  92. }
  93.  
  94. DEF SwitchTime TimeSensor {
  95.     cycleInterval 5
  96. }
  97.  
  98. DEF S Script {
  99.     eventIn SFBool isActive
  100.     field MFString anchorURL IS url 
  101.     url "vrmlscript:
  102.         function isActive(value) {
  103.             if (!value) Browser.loadURL(anchorURL, '');
  104.         }"
  105. }
  106.  
  107. ROUTE PS.enterTime TO Time.startTime
  108. ROUTE Time.fraction_changed TO TP_COLOR.set_fraction
  109. ROUTE Time.fraction_changed TO TP_TRANSP.set_fraction
  110. ROUTE TP_COLOR.value_changed TO TP_MAT.set_emissiveColor
  111. ROUTE TP_TRANSP.value_changed TO TP_MAT.set_transparency
  112. ROUTE PS.enterTime TO SwitchTime.startTime
  113. ROUTE SwitchTime.isActive TO S.isActive
  114.  
  115. }
  116.  
  117.